
#include<cstdio>
#include<cstring>
char a[105][105];
int main()
{
    int t;
    int n,m;
    scanf("%d",&t);
    for(int k = 1;k<=t;k++)
    {
        int num = 0;
        scanf("%d%d",&n,&m);
        for(int i = 0;i<n;i++){
            for(int j = 0;j<m;j++){
                scanf("%c",&a[i][j]);
                if(a[i][j]=='O')
                    num++;
            }
        }

        if(num==0)
        {
            printf("Case %d: Fat brother\n",k);
        }
        else
        {
            if(num%2==0)
                printf("Case %d: Fat brother\n",k);

            else
                printf("Case %d: Maze\n",k);
        }

    }

    return 0;
}
